<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
    <style>
        .layui-card {
            border: 1px solid #f2f2f2;
            border-radius: 5px;
        }

        .layuimini-qiuck-module a i {
            display: inline-block;
            width: 100%;
            height: 60px;
            line-height: 60px;
            text-align: center;
            border-radius: 2px;
            font-size: 30px;
            background-color: #F8F8F8;
            color: #333;
            transition: all .3s;
            -webkit-transition: all .3s;
        }

        .layuimini-qiuck-module a cite {
            position: relative;
            top: 2px;
            display: block;
            color: #666;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            font-size: 14px;
        }

        .welcome-module {
            width: 100%;
        }

        .panel {
            background-color: #fff;
            border: 1px solid transparent;
            border-radius: 3px;
            -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
            box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
            text-align: center;
        }

        .panel-body {
            padding: 10px
        }

        .panel-title {
            margin-top: 0;
            margin-bottom: 0;
            font-size: 12px;
            color: inherit
        }

        .main_btn > p {
            height: 40px;
        }

        .layui-bg-number {
            background-color: #F8F8F8;
        }

        .no-margins {
            color: #00a2d4;
        }

    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <!--<fieldset class="table-search-fieldset">-->
            <div class="layui-row layui-col-space10">
                <form class="layui-form layui-form-pane" action="" >
                    <div style="margin: 10px 10px 10px 10px;">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">搜索信息</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="search" autocomplete="off" placeholder="手机号、昵称、ID搜索" class="layui-input soso">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <select name="" id="industry" lay-filter="chooseIndustry">
                                    <option value="">行业筛选</option>
                                    industry
                                    {volist name='industry' id='v'}
                                        <option value="{$v.id}" title="{$v.level}">{$v.title}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="" id="valueSection" lay-filter="valueSection">
                                    <option value="">价值区间</option>

                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="" lay-filter="precedence">
                                    <option value="">优先等级</option>
                                    <option value="1">优先</option>
                                    <option value="2">不优先</option>

                                </select>
                            </div>
                            <div class="layui-inline">
                                <select lay-filter="plurs_grid">
                                    <option value="">匹配要求</option>
                                    <option value="0">可全部匹配</option>
                                    <option value="1">空一格可匹配</option>
                                    <option value="2">空二格可匹配</option>
                                    <option value="3">空三格可匹配</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="" id="" lay-filter="status">
                                    <option value="1">已出售</option>
                                    <option value="2">出售中</option>
                                    <option value="3">已完成</option>
                                </select>
                            </div>
                            <div class="layui-inline" style="display: none">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>

                    </div>
                </form>
                <div class="layui-col-xs2" style="width:10%;" onclick="lanuchSale('today')">
                    <div class="panel layui-bg-number">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h2>今日投放交易额</h2>
                            </div>
                            <div class="panel-content">
                                <h2 class="no-margins">{$today}</h2>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs2" style="width:10%;" onclick="lanuchSale('yestoday')">
                    <div class="panel layui-bg-number">
                        <div class="panel-body">
                            <div class="panel-title">
                                <h2>昨日投放交易额</h2>
                            </div>
                            <div class="panel-content">
                                <h2 class="no-margins">{$yestoday}</h2>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <!--</fieldset>-->
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="detail">查看详情</a>
        </script>
        <input type="hidden" id="memberCode">
    </div>
</div>
{include file="public/footer" /}
<script>
    var form;
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            table = layui.table;
            form = layui.form;
        /*用户卡券*/
        table.render({
            elem: '#currentTableId',
            url: '/admin/TransactionData/lanunch_list?action=ajax',
            method: 'post',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data, //解析数据列表
                };
            },
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'name', title: '账号名称', sort: false, align: 'center'},
                {field: 'phone', title: '手机号', sort: false, align: 'center'},
                {field: 'code', title: 'ID', sort: false, align: 'center'},
                {field: 'teamCount', title: '团队数量', sort: true, align: 'center'},
                {field: 'waitCount', title: '待出售数量', sort: true, align: 'center'},
                {field: 'waitPrice', title: '待出售金额', sort: true, align: 'center'},
                {field: 'alreadyCount', title: '已出售数量', sort: true, align: 'center',event:'alreadyClick'},
                {field: 'alreadyPrice', title: '已出售金额', sort: true, align: 'center'},
                {field: 'settlementPrice', title: '待结算金额', sort: true, align: 'center'},
                {title: '操作', toolbar: '#currentTableBar', align: 'center'}
            ]],
            limits: [ 20, 25, 30, 50, 100],
            limit: 20,
            page: false,
            skin: 'line,row',
            done: function (res, curr, count) {

            }
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    search:data.field.search
                }
            }, 'data');
            return false;
        });
        form.on('select(chooseIndustry)', function(data){
            changeSection(data.elem[data.elem.selectedIndex].title)
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    industryId:data.value
                }
            }, 'data');
            return false;
        });
        form.on('select(valueSection)', function(data){
            let min=data.value
            let max=data.elem[data.elem.selectedIndex].title
            let industry_id=$("#industry :selected").val();
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    industryId:industry_id,
                    min:min,
                    max:max,
                }
            }, 'data');
            return false;
        });
        form.on('select(precedence)', function(data){
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    precedence:data.value,
                }
            }, 'data');
            return false;
        });
        form.on('select(plurs_grid)', function(data){
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    plurs_grid:data.value,
                }
            }, 'data');
            return false;
        });
        form.on('select(status)', function(data){
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    status:data.value,
                }
            }, 'data');
            return false;
        });
        /*投放行业*/
        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.open({
                    type: 2,
                    title: '查看详情',
                    shadeClose: true,
                    shade: 0.5,
                    area: ['100%', '100%'],
                    content: '/admin/TransactionData/lanunch_detail?code='+data.code,
                    end: function () {
                        location.reload();
                    }
                });
            }
            if (obj.event=='alreadyClick'){
                layer.open({
                    type: 2,
                    title: '交易信息',
                    shadeClose: true,
                    shade: 0.5,
                    area: ['100%', '100%'],
                    content: '/admin/PlatformData/tradAudit?action=view&lanunchdetail=1&member_phone='+data.phone,
                    end: function () {
                    }
                });
            }
        });

    });

    function changeSection(level)
    {
        let str='<option value="">价值区间</option>';
        if(level!=''){
            $.ajax({
                url:'/admin/TransactionData/changeSection',
                type:'post',
                data:{
                  level:level
                },
                dataType:'json',
                async:false,
                success:function(res){
                    res.section.forEach(v=>{
                        str+='<option value="'+v[0]+'" title="'+v[1]+'">'+v[0]+'~'+v[1]+'</option>'
                    })

                }
            })
        }
        $("#valueSection").html(str);
        form.render();
    }
    function lanuchSale(mark){
        layer.open({
            type: 2,
            title: '投放交易额',
            shadeClose: true,
            shade: 0.5,
            area: ['100%', '100%'],
            content: '/admin/TransactionData/lanunch_sale?mark='+mark,
            end: function () {
                location.reload();
            }
        });
    }
</script>

</body>
</html>